{include file='public:header-css'/}
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    {include file='public:left-menu'/}
    <!--End 左侧导航-->
    <!--头部信息-->
    {include file='public:nav-header' title="订单管理" subTitle="商城订单详情"/}
    <!--End 头部信息-->

    <!--页面主要内容-->
    <main class="lyear-layout-content">

      <div class="container-fluid">

        <div class="row">
          <div class="col-md-12">
            <div class="card">
              <div class="card-header" style="display: flex;align-items: center;justify-content: space-between">
                <h4>基本信息</h4>
                <a style="border-radius: 3px" class="btn btn-label btn-theme" target="_blank" href="{:url('Order/order_print',['order_id'=>$info.order_id])}"><label><i
                        class="mdi mdi-printer"></i></label> 打印订单</a>
              </div>
              <div class="card-body info">
                <div class="form-inline">
                  <span class="tit">订单ID:</span>
                  <span class="text">{$info.order_id}</span>
                </div>
                <div class="form-inline">
                  <span class="tit">订单编号:</span>
                  <span class="text">{$info.order_sn}</span>
                </div>
                <div class="form-inline">
                  <span class="tit">真实姓名:</span>
                  <span class="text">{$info.user.realname|default='无'}</span>
                </div>
                <div class="form-inline">
                  <span class="tit">会员ID:</span>
                  <span class="text">{$info.user_id}</span>
                </div>
                <div class="form-inline">
                  <span class="tit">会员手机:</span>
                  <span class="text">{$info.user.mobile}</span>
                </div>
                <div class="form-inline">
                  <span class="tit">订单状态:</span>
                  <span class="text">{$info.order_status_text}</span>
                </div>
                <div class="form-inline">
                  <span class="tit">支付方式:</span>
                  <span class="text">{$info.pay_name}</span>
                </div>
                <div class="form-inline">
                  <span class="tit">所属商家:</span>
                  <span class="text">{$info.store.store_name}</span>
                </div>
                  <div class="form-inline">
                      <span class="tit">用户备注:</span>
                      <span class="text">{$info.user_note|default='无'}</span>
                  </div>
                <div class="form-inline">
                  <span class="tit">创建时间:</span>
                  <span class="text">{$info.add_time}</span>
                </div>
                <div class="form-inline">
                  <span class="tit">支付时间:</span>
                  <span class="text">{$info.pay_time_text}</span>
                </div>
                <div class="form-inline">
                  <span class="tit">收货时间:</span>
                  <span class="text">{$info.confirm_time_text}</span>
                </div>
                <div class="form-inline">
                  <span class="tit">取消时间:</span>
                  <span class="text">{$info.cancel_time_text}</span>
                </div>
              </div>
            </div>
          </div>
          <div class="col-md-12">
            <div class="card">
              <div class="card-header">
                <h4>奖励信息</h4>
              </div>
              <div class="card-body info">
                <div class="form-inline">
                  <span class="tit">分销奖励:</span>
                  <span class="text">{$info.award}</span>
                </div>
              </div>
            </div>
          </div>
          <div class="col-md-12">
            <div class="card">
              <div class="card-header"><h4>收货信息</h4></div>
              <div class="card-body">
                <table class="table table-bordered" style="margin-bottom: 0">
                  <thead>
                  <tr>
                    <th>收货人</th>
                    <th>联系方式</th>
                    <th>收货地址</th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr>
                    <td>{$info.consignee}</td>
                    <td>{$info.mobile}</td>
                    <td>{$info.all_address}</td>
                  </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
          {if $info.shipping_name && $info.shipping_code && $info.shipping_time}
          <div class="col-md-12">
            <div class="card">
              <div class="card-header"><h4>发货信息</h4></div>
              <div class="card-body">
                <table class="table table-bordered" style="margin-bottom: 0">
                  <thead>
                  <tr>
                    <th>快递编码</th>
                    <th>快递公司</th>
                    <th>快递单号</th>
                    <th>发货时间</th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr>
                    <td>{$info.shipping_code}</td>
                    <td>{$info.shipping_name}</td>
                    <td>{$info.shipping_number}</td>
                    <td>{$info.shipping_time_text}</td>
                  </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
          {/if}
          <div class="col-md-12">
            <div class="card">
              <div class="card-header"><h4>商品信息</h4></div>
              <div class="card-body">
                <table class="table table-bordered table-hover" style="margin-bottom: 10px">
                  <thead>
                  <tr>
                    <th>商品编号</th>
                    <th>商品名称</th>
                    <th>商品规格</th>
                    <th>商品价格</th>
                    <th>商品数量</th>
                    <th>商品小计</th>
                  </tr>
                  </thead>
                  <tbody>
                  {volist name="$info.order_goods" id="goods"}
                  <tr>
                    <td>{$goods.goods_sn|default='无'}</td>
                    <td>{$goods.goods_name}</td>
                    <td>{$goods.item_name|default='无'}</td>
                    <td>{$goods.goods_price}</td>
                    <td>{$goods.goods_num}</td>
                    <td>{$goods.goods_price*$goods.goods_num}</td>
                  </tr>
                  {/volist}
                  </tbody>
                </table>
                <div class="order-amount">
                  <span class="tit">订单总额:</span>
                  <span class="money">￥{$info.total_amount}</span>
                  <span class="tit">运费:</span>
                  <span class="money">￥{$info.ship_price}</span>
                  <span class="tit">实际支付:</span>
                  <span class="money">￥{$info.order_amount}</span>
                </div>
              </div>
            </div>
          </div>
          {if $info.order_status>0}
          <div class="col-md-12">
            <div class="card">
              <div class="card-header"><h4>订单发货</h4></div>
              <div class="card-body">
                <form action="" id="submit-form" method="post">
                  <div class="form-group">
                    <label>快递编码</label>
                    <div>
                      <select class="input-group-select w-100" id="shipping_code" name="shipping_code">
                        <option value="">请选择</option>
                        {volist name="$shipping" id="shipping"}
                        <option value="{$key}" {if $info.shipping_code==$key}selected{/if}>{$shipping}</option>
                        {/volist}
                      </select>
                    </div>
                    <span class="help">快递编码<a href="https://api.kuaidi100.com/manager/page/document/kdbm" target="_blank"> 查看https://api.kuaidi100.com/manager/page/document/kdbm</a></span>
                  </div>
                  <div class="form-group">
                    <label for="shipping_name">快递公司</label>
                    <input class="form-control" value="{$info.shipping_name}" id="shipping_name" type="text" name="shipping_name" placeholder="请输入快递公司">
                  </div>
                  <div class="form-group">
                    <label for="shipping_number">快递单号</label>
                    <input class="form-control" value="{$info.shipping_number}" type="text" id="shipping_number" name="shipping_number" placeholder="请输入快递单号">
                  </div>
                  <div>
                    <input type="hidden" name="{$info.pk}" value="{$info[$info.pk]}">
                    <button class="btn btn-theme submit-btn" type="button">
                      {if $info.order_status==1}
                      发货
                      {else/}
                      修改
                      {/if}
                    </button>
                  </div>
                </form>
              </div>
            </div>
          </div>
          {/if}
        </div>

      </div>

    </main>
    <!--End 页面主要内容-->
  </div>
  <style>
    .card{
      margin-bottom: 10px;
    }
    .info{
      display: flex;
      flex-wrap: wrap;
    }
    .info .form-inline{
      width: 50%;
      min-height: 38px;
    }
    .info .form-inline .tit{
      font-weight: normal;
      margin-right: 5px;
    }
    .info .form-inline .text{
      font-weight: 700;
    }
    .info .form-inline img{
      width: 90px;
      height: 90px;
    }
    .order-amount{
      display: flex;
      justify-content: flex-end;
    }
    .order-amount .money{
      margin-left: 5px;
      font-weight: 700;
    }
    .order-amount .money:not(:last-child){
      margin-right: 5px;
    }
  </style>
</div>

<script type="text/javascript">
  $(function(){
    $('#shipping_code').on('change',function () {
      var val=$('#shipping_code option:selected').text();
      $('#shipping_name').val(val);
    });
    $('.submit-btn').click(function () {
      var url = "{:url('Order/order_send',[$info.pk=>$info[$info.pk]])}";
      var data = $('#submit-form').serialize();
      $.ajax({
        type: "POST",
        url: url,
        data: data,
        dataType: 'json',
        success: function (data) {
          if (data.code == 1) {
            showSuccessMsg(data.msg, function () {
              location.reload();
            });
          }  else {
            showErrorMsg(data.msg);
          }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            showErrorMsg("网络失败，请刷新后重试!");
        }
      });
    });
  });
</script>
</body>
</html>
